package blog.modelo;

// Generated Oct 24, 2014 1:54:18 PM by Hibernate Tools 4.3.1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * BlogPost generated by hbm2java
 */
@Entity
@Table(name = "blog_post",  uniqueConstraints = @UniqueConstraint(columnNames = "title_clean"))
public class BlogPost implements java.io.Serializable {

	private Integer id;
	private BlogAuthor blogAuthor;
	private String title;
	private String article;
	private String titleClean;
	private String file;
	private Date datePublished;
	private String bannerImage;
	private boolean featured;
	private boolean enabled;
	private boolean commentsEnabled;
	private int views;
	private Set<BlogComment> blogComments = new HashSet<BlogComment>(0);
	private Set<BlogTag> blogTags = new HashSet<BlogTag>(0);
	private Set<BlogCategory> blogCategories = new HashSet<BlogCategory>(0);
	private Set<BlogRelated> blogRelateds = new HashSet<BlogRelated>(0);

	public BlogPost() {
	}

	public BlogPost(BlogAuthor blogAuthor, String title, Date datePublished,
			boolean featured, boolean enabled, boolean commentsEnabled,
			int views) {
		this.blogAuthor = blogAuthor;
		this.title = title;
		this.datePublished = datePublished;
		this.featured = featured;
		this.enabled = enabled;
		this.commentsEnabled = commentsEnabled;
		this.views = views;
	}

	public BlogPost(BlogAuthor blogAuthor, String title, String article,
			String titleClean, String file, Date datePublished,
			String bannerImage, boolean featured, boolean enabled,
			boolean commentsEnabled, int views, Set<BlogComment> blogComments,
			Set<BlogTag> blogTags, Set<BlogCategory> blogCategories,
			Set<BlogRelated> blogRelateds) {
		this.blogAuthor = blogAuthor;
		this.title = title;
		this.article = article;
		this.titleClean = titleClean;
		this.file = file;
		this.datePublished = datePublished;
		this.bannerImage = bannerImage;
		this.featured = featured;
		this.enabled = enabled;
		this.commentsEnabled = commentsEnabled;
		this.views = views;
		this.blogComments = blogComments;
		this.blogTags = blogTags;
		this.blogCategories = blogCategories;
		this.blogRelateds = blogRelateds;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "author_id", nullable = false)
	public BlogAuthor getBlogAuthor() {
		return this.blogAuthor;
	}

	public void setBlogAuthor(BlogAuthor blogAuthor) {
		this.blogAuthor = blogAuthor;
	}

	@Column(name = "title", nullable = false, length = 144)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "article", length = 65535)
	public String getArticle() {
		return this.article;
	}

	public void setArticle(String article) {
		this.article = article;
	}

	@Column(name = "title_clean", unique = true, length = 144)
	public String getTitleClean() {
		return this.titleClean;
	}

	public void setTitleClean(String titleClean) {
		this.titleClean = titleClean;
	}

	@Column(name = "file", length = 45)
	public String getFile() {
		return this.file;
	}

	public void setFile(String file) {
		this.file = file;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date_published", nullable = false, length = 19)
	public Date getDatePublished() {
		return this.datePublished;
	}

	public void setDatePublished(Date datePublished) {
		this.datePublished = datePublished;
	}

	@Column(name = "banner_image", length = 144)
	public String getBannerImage() {
		return this.bannerImage;
	}

	public void setBannerImage(String bannerImage) {
		this.bannerImage = bannerImage;
	}

	@Column(name = "featured", nullable = false)
	public boolean isFeatured() {
		return this.featured;
	}

	public void setFeatured(boolean featured) {
		this.featured = featured;
	}

	@Column(name = "enabled", nullable = false)
	public boolean isEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	@Column(name = "comments_enabled", nullable = false)
	public boolean isCommentsEnabled() {
		return this.commentsEnabled;
	}

	public void setCommentsEnabled(boolean commentsEnabled) {
		this.commentsEnabled = commentsEnabled;
	}

	@Column(name = "views", nullable = false)
	public int getViews() {
		return this.views;
	}

	public void setViews(int views) {
		this.views = views;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "blogPost")
	public Set<BlogComment> getBlogComments() {
		return this.blogComments;
	}

	public void setBlogComments(Set<BlogComment> blogComments) {
		this.blogComments = blogComments;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "blogPost")
	public Set<BlogTag> getBlogTags() {
		return this.blogTags;
	}

	public void setBlogTags(Set<BlogTag> blogTags) {
		this.blogTags = blogTags;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "blog_post_to_category",  joinColumns = { @JoinColumn(name = "post_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "category_id", nullable = false, updatable = false) })
	public Set<BlogCategory> getBlogCategories() {
		return this.blogCategories;
	}

	public void setBlogCategories(Set<BlogCategory> blogCategories) {
		this.blogCategories = blogCategories;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "blogPost")
	public Set<BlogRelated> getBlogRelateds() {
		return this.blogRelateds;
	}

	public void setBlogRelateds(Set<BlogRelated> blogRelateds) {
		this.blogRelateds = blogRelateds;
	}

}
